var mongodb = require('./mongodbModel');
var Schema = mongodb.mongoose.Schema;

var userSchema = new Schema({
    userName : String,
    userInfo : {
        age : Number,
        sex : String,
    },
    userHobby : [String,String,String]
},{ collection: 'myapp'});

var userModel = mongodb.mongoose.model("User",userSchema);
var users = function(){};
// 保存
users.prototype.create = function(docs,callback){
    this.create(docs,function(err){
        callback(err);
    });
};
// 按用户名精确查询
users.prototype.findByName = function(userName,callback){
    userModel.findOne({userName : userName},function(obj,err){
        callback(err,obj);
    });
};

module.exports = userModel;